/* -----------------------------------------------------------------------
 * Christine Hayes
 * Using provided template testUpdateCoins.c
 * This test is for the fullDeckCount function.
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

// set NOISY_TEST to 0 to remove printfs from output
#define NOISY_TEST 1

int main() {
	int i;
    int seed = 1000;
    int numPlayer = 2;
    int p, r, handCount;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    int maxHandCount = 5;

	//return value for fullDeckCount
	int count;
	
	//Adjustment factor for each player
	int playerAdj = 0;
	
	//Fill hand with copper (could be anything)
	int coppers[MAX_HAND];
	for (i = 0; i < MAX_HAND; i++)
    {
        coppers[i] = copper;
    }
	
    printf ("TESTING fullDeckCount():\n");
    for (p = 0; p < numPlayer; p++)
    {

        for (handCount = 1; handCount <= maxHandCount; handCount++)
        {
            
#if (NOISY_TEST == 1)
                printf("Test player %d with %d treasure card(s).\n", p, handCount);
#endif
                memset(&G, 23, sizeof(struct gameState));   // clear the game state
                r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
                G.handCount[p] = handCount;                 // set the number of cards on hand
				memcpy(G.hand[p], coppers, sizeof(int) * handCount); // set all the cards to copper
				
                count = fullDeckCount(p, 1, &G); //get fullDeckCount
#if (NOISY_TEST == 1)
                printf("Count = %d, expected = %d\n", count, 2 + playerAdj);
#endif
                assert(count == 2 + playerAdj); // check if the number of cards
            
        }
		playerAdj++;
    }

    printf("All tests passed!\n");

    return 0;
}